export default class Util_Projection{
  constructor(){

  }
  static webMercator2LngLat(x,y){//[12727039.383734727, 3579066.6894065146]
    var lng = x / 20037508.34 * 180;
    var lat = y / 20037508.34 * 180;
    lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);
    return [lng, lat]; //[114.32894001591471, 30.58574800385281]
  }
  static lngLat2WebMercator(lng,lat) {//[114.32894, 30.585748]
    var mercator = {};
    var earthRad = 6378137.0;
    // console.log("mercator-poi",poi);
    mercator.x = lng * Math.PI / 180 * earthRad;
    var a = lat * Math.PI / 180;
    mercator.y = earthRad / 2 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
    // console.log("mercator",mercator);
    return mercator; //[12727039.383734727, 3579066.6894065146]
  }
}
